var ConsultantInfoDlg = {
    consultantInfoData: {},
    zTreeInstance: null,
    validateFields: {}
};
//清除数据
ConsultantInfoDlg.clearData = function () {
    this.consultantInfoData = {};
};
//设置对话框中的数据 @param key 数据的名称 @param val 数据的具体值
ConsultantInfoDlg.set = function (key, val) {
    this.consultantInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
};
//设置对话框中的数据 @param key 数据的名称 @param val 数据的具体值
ConsultantInfoDlg.get = function (key) {
    return $("#" + key).val();
};
//关闭此对话框
ConsultantInfoDlg.close = function () {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
};

ConsultantInfoDlg.showConsultantSelectTree = function () {
    var pName = $("#pName");
    var pNameOffset = $("#pName").offset();
    $("#parentConsultantMenu").css({
        left: pNameOffset.left + "px",
        top: pNameOffset.top + pName.outerHeight() + "px"
    }).slideDown("fast");
    $("body").bind("mousedown", onBodyDown);
};

ConsultantInfoDlg.hideConsultantSelectTree = function () {
    $("#parentConsultantMenu").fadeOut("fast");
    $("body").unbind("mousedown", onBodyDown);// mousedown当鼠标按下就可以触发，不用弹起
};

ConsultantInfoDlg.collectData = function () {
    this.set('id').set('supplementOfPayment').set('reservationsId').set('totleFoldingPay').set('diagnosisContent').set('amountOfPayment').set('operationTime');
};

ConsultantInfoDlg.validate = function () {
    $('#consultantInfoForm').data("bootstrapValidator").resetForm();
    $('#consultantInfoForm').bootstrapValidator('validate');
    return $("#consultantInfoForm").data('bootstrapValidator').isValid();
};

function onBodyDown(event) {
    if (!(event.target.id == "menuBtn" || event.target.id == "parentConsultantMenu" || $(event.target).parents("#parentConsultantMenu").length > 0)) {
        ConsultantInfoDlg.hideConsultantSelectTree();
    }
};

$(function () {
    Feng.initValidator("consultantInfoForm", ConsultantInfoDlg.validateFields);
});